"""SQL запросы."""

SLQ_LAB_SEL_ISP = """SELECT pl_uslt.idkv,pl_uslt.teh,pl_uslt.lit,pl_uslt.varh,pl_uslt.dzr
from pl_uslt
Where (pl_uslt.idkv = {idkv});"""

# Проверка исполнителей в таблице этапов------------------------------------------
SLQ_LAB_CHK_TEH = """SELECT * from PL_USLB where SDL=35 and idkv={idkv};"""
SLQ_LAB_CHK_LIT = """SELECT * from PL_USLB where SDL=37 and idkv={idkv};"""
SLQ_LAB_CHK_POL = """SELECT * from PL_USLB where SDL=36 and idkv={idkv};"""
SLQ_LAB_CHK_CADCAM = """SELECT * from PL_USLB where SDL=38 and idkv={idkv};"""
# Генерация поля IDUS для исполнителей
SLQ_LAB_IDUS = """SELECT max(idus) as idus from pl_uslp where idkv={idkv};"""
# Запись исполнителей-----------------------
SQL_LAB_SEL_DOC = """SELECT doc from n_doc where mpp={mpp} and mol=1;"""
SLQ_LAB_UPD_TEH = """UPDATE PL_USLB SET UID={uid},
                                        IDUS={idus},
                                        MPP={nom_teh},
                                        SDL=35,
                                        IDKV={idkv},
                                        DOU={dou},
                                        DOC={doc},
                                        DLJ=124
                                        WHERE idbr={idbr};"""
SLQ_LAB_UPD_POL = """UPDATE PL_USLB SET UID={uid},
                                        IDUS={idus},
                                        MPP={nom_pol},
                                        SDL=36,
                                        IDKV={idkv},
                                        DOU={dou},
                                        DOC={doc},
                                        DLJ=162
                                        WHERE idbr={idbr}"""
SLQ_LAB_UPD_LIT = """UPDATE PL_USLB SET UID={uid},
                                        IDUS={idus},
                                        MPP={nom_lit},
                                        SDL=37,
                                        IDKV={idkv},
                                        DOU={dou},
                                        DOC={doc},
                                        DLJ=163
                                        WHERE idbr={idbr}"""
SLQ_LAB_UPD_CADCAM = """UPDATE PL_USLB SET UID={uid},
                                        IDUS={idus},
                                        MPP={nom_cadcam},
                                        SDL=38,
                                        IDKV={idkv},
                                        DOU={dou},
                                        DOC={doc},
                                        DLJ=124
                                        WHERE idbr={idbr}"""

SQL_LAB_INS_ISP = """INSERT INTO PL_USLT (idkv,teh,lit,varh,polir,dzr)
    values({idkv},{nom_teh},{nom_lit},{nom_var},{nom_pol},{dzr})"""
SQL_LAB_UPD_ISP = """Update pl_uslt
                              set teh={nom_teh},
                                  lit={nom_lit},
                                  varh={nom_var},
                                  polir={nom_pol},
                                  dzr={dzr}
                              where idkv={idkv}"""

SQL_ZN_NARYAD_UPDATE_USLK = """Update pl_uslk
                              set
                                  dzr={dzr},
                                  status={status},
                                  pdog=1
                              where idkv={idkv}"""

SQL_ZN_NARYAD_DZR_USLK = """select dzr from pl_uslk
                              where idkv={idkv}"""
